//
//  TelephoneGroupTableViewCell.m
//  mcrmSAAS
//
//  Created by wjxfhxy on 15-4-15.
//  Copyright (c) 2015年 GuangZhouXuanWu. All rights reserved.
//

#import "TelephoneGroupTableViewCell.h"

@implementation TelephoneGroupTableViewCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setKeyBoarType:XUINumberKeyboardTypeInteger];
    }
    return self;
}

@end

@interface TelephoneStaticTextGroupTableViewCell()<XUIButtonDelegate>
{
    XUIButton *_callBtn;
}
@end

@implementation TelephoneStaticTextGroupTableViewCell 

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    _callBtn = [XUIButton buttonWithStyleType:XUIButtonStyleTypeCenterImage delegate:self];
    [_callBtn SetImage:[UIImage imageNamed:@"btn_contact_phone.png"]];
    _callBtn.size = CGSizeMake(36, 36);
    [self.contentView addSubview:_callBtn];
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _callBtn.right = self.contentView.width - 10;
    _callBtn.centerY = self.contentView.height /2;
}

+(CGFloat)textMaxContainWidth:(CGFloat)containWidth
{
    return [StaticTextGroupTableViewCell textMaxContainWidth:containWidth] - [UIImage imageNamed:@"btn_contact_phone.png"].size.width - 10;
}

-(void)setText:(NSString *)text
{
    [super setText:text];
    
    if(text.length > 0 && [text isBlankString] == NO)
    {
        _callBtn.hidden = NO;
    }
    else
    {
        _callBtn.hidden = YES;
    }
}

-(void)clickedUpInsideOfButton:(XUIButton *)btn
{
    [(id<TelephoneStaticTextGroupTableViewCellDelegate>)self.delegate telephoneStaticTextGroupTableViewCell:self didClickPhoneButton:nil];
}

@end